Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve filter_extremes methods in Dictionary and HashDictionary #2303

Merged
merged 1 commit into from
Jan 9, 2019

Conversation

horpto
Copy link
Contributor

@horpto horpto commented Dec 19, 2018

  • use search by set instead of list
  • refine default value of dict.get() method
  • inplace sort

- use search by set instead of list
- refine default value of dict.get() method
- inplace sort
)
good_ids = sorted(good_ids, key=lambda x: self.num_docs if x in keep_ids else self.dfs.get(x), reverse=True)
]
good_ids.sort(key=lambda x: self.num_docs if x in keep_ids else self.dfs.get(x, 0), reverse=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why sorted(generator) -> list.sort()? Is this save memory or what's a difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It saves me from linter XD
No, it does not save memory https://github.com/python/cpython/blob/master/Python/bltinmodule.c#L2201

@menshikh-iv menshikh-iv changed the title Improve filter_extremes methods in Dictionary and HashDictionary Improve filter_extremes methods in Dictionary and HashDictionary Jan 9, 2019
@menshikh-iv
Copy link
Contributor

Thanks @horpto

@menshikh-iv menshikh-iv merged commit 7cbf715 into piskvorky:develop Jan 9, 2019
@piskvorky
Copy link
Owner

Awesome! These are the kind of deep and small but important fixes that help us so much. 👍

@horpto horpto deleted the dictionary-keep_ids branch January 19, 2019 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants